﻿using MB.Orm.DB;
using MB.RuleBase.Common;
using Model;
using Public.DataAccess;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Business.Service
{
    public class BDCwarehouse
    {
        public BDCwarehouse() { }
        /// <summary>
        /// 获取前置仓仓库信息
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="total"></param>
        /// <param name="parValues"></param>
        /// <returns></returns>
        public List<DCwarehouse> GetDCwarehouseInfo(int pageIndex, int pageSize, out int total, params object[] parValues)
        {
            using (var DbScope = new OperationDatabaseScope(new OperationDatabaseContext("NewWeb")))
            {
                List<DCwarehouse> list = PagedDatabaseExcuteByXmlHelper.NewInstance.GetPagedObjectsByXml3<DCwarehouse>
                                                ("DCDBA", "GetDCwarehouseInfo", pageIndex, pageSize, out total, parValues);
                return list;
            }
        }
        /// <summary>
        /// 查询前置仓编号是否存在
        /// </summary>
        /// <param name="seedType"></param>
        /// <returns></returns>
        public List<DCwarehouse> GetDCwarehouseByCode(string code)
        {
            using (var DbScope = new OperationDatabaseScope(new OperationDatabaseContext("NewWeb")))
            {
                List<DCwarehouse> lmWarrantyTimelist = DatabaseExcuteByXmlHelper.NewInstance.GetObjectsByXml<DCwarehouse>("DCDBA", "GetDCwarehouseByCode", code);
                return lmWarrantyTimelist;
            }
        }
        /// <summary>
        /// 新增前置仓仓库信息
        /// </summary>
        /// <param name="dCwarehouse"></param>
        /// <returns></returns>
        public int AddDCwarehouse(DCwarehouse dCwarehouse)
        {
            return DatabaseExcuteByXmlHelper.NewInstance.ExecuteNonQueryByEntity<DCwarehouse>("DCDBA", "AddDCwarehouse", dCwarehouse);
        }
        /// <summary>
        /// 更新前置仓仓库信息
        /// </summary>
        /// <param name="dCwarehouse"></param>
        /// <returns></returns>
        public int UpdateDCwarehouse(DCwarehouse dCwarehouse)
        {
            return DatabaseExcuteByXmlHelper.NewInstance.ExecuteNonQueryByEntity<DCwarehouse>("DCDBA", "UpdateDCwarehouse", dCwarehouse);
        }


        /// <summary>
        /// 获取前置仓仓库
        /// </summary>
        /// <param name="seedType"></param>
        /// <returns></returns>
        public List<Warehouse> GetDCWarehouseList(string defaultValue)
        {
            using (var DbScope = new OperationDatabaseScope(new OperationDatabaseContext("NewWeb")))
            {
                List<Warehouse> lmSeedlist = DatabaseExcuteByXmlHelper.NewInstance.GetObjectsByXml<Warehouse>("DCDBA", "GetDCwarehouseInfo");
                if (defaultValue != null && defaultValue != "")
                {
                    lmSeedlist.Add(new Warehouse() { WAREHOUSEID = 0, WAREHOUSECODE = "0", WAREHOUSENAME = defaultValue });

                }
                return lmSeedlist;
            }
        }
    }
}
